define(function (require,exports,module) {
    var sTpl = require("./template.html");

    var VueComponent = Vue.extend({
        props: ['parentData'],
        template: sTpl,
        data:function () {

            return {
                form: {
                    roomId:'',
                    flightInfoId:''
                },
                planes:[],
                rooms:[],
                enterOpen:true,
                enterData:{
                    editOrAdd:'add'
                },
                sigIns:[],
                slidingWindowVisible1:false,
                url:basepath+"/api/signIn/queryService"
            }
        },methods:{
            querySignInService:function () {
               var url=basepath+"/api/signIn/queryService?roomId="+this.form.roomId+"&flightInfoId="+this.form.flightInfoId;
               if(this.url==url){
                   this.$refs.flightPlane.freshTableList();
               }
               this.url= url;
            },openSide:function () {
                if(!this.slidingWindowVisible1)
                    this.slidingWindowVisible1 = true;
            },processor:function(data){
                data.forEach(function(da){
                    da.remindIng=false;
                })
                this.sigIns=data;
                return data;
            },
            remind:function (scope,index) {
                var data=scope;
                var $this=this;
                data.remindTime+=1;
                $this.sigIns[index].remindIng= true;
                axios.post(basepath+"/api/signIn/save", {signInPo:data, appointmentPo:{}}).then(function (response) {
                    scope.remindIng=false;
                    $this.$notify({tittle:"保存成功",message:"登机提醒保存成功"})
                })
            },
            checkedOut:function(scope){
                var $this = this;
                this.$confirm('确定要退房么？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'success'
                }).then(function() {
                    scope.room.roomStatus="1";
                    axios.post(basepath+'/api/room/saveRoom',scope.room)
                        .then(function (response) {
                           // $this.$refs.flightPlane.internalData.splice(scope.$index,1);
                            $this.$notify({
                                title: '退房成功',
                                message: '退房成功'
                            });
                        });
                });
            },serviceEnd:function(scope,index){
                var $this = this;

                this.$confirm('确定要结束么？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'success'
                }).then(function() {
                    if(scope.room){
                        scope.room.roomStatus="1";
                    }
                    scope.serviceStatus="服务结束";
                    scope.passengerStatus="end";
                    axios.post(basepath+"/api/signIn/save", {signInPo:scope, appointmentPo:{}}).then(function (response) {
                        scope.remindIng=false;
                         $this.$refs.flightPlane.internalData.splice(scope.$index,1);
                        $this.$notify({tittle:"保存成功",message:"服务已结束"})
                    })
                });
            }


        },
        created:function () {

            var $this=this;
            axios.get("/dam/api/flightInfo/queryFlightInfo?filter=").then(function (response) {
                $this.planes=response.data;
            })
            axios.get("/dam/api/room/queryRoom?filter=").then(function (response) {
                $this.rooms=response.data;

            })
        },
        activated:function () {
            messages.$emit('change','服务动态管理');
        }
    })
    module.exports=VueComponent;
    module.exports.reDefine=function (val) {
        module.exports.type=val;
        return module.exports;
    }

})